package io.renren.modules.recruit_info.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.recruit_info.entity.RecruitmentInforEntity;
import io.renren.modules.recruit_info.service.RecruitmentInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 招聘信息表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-12-30 15:44:44
 */
@RestController
@RequestMapping("recruit_info/recruitmentinfor")
public class RecruitmentInforController {
    @Autowired
    private RecruitmentInforService recruitmentInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("recruit_info:recruitmentinfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = recruitmentInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{departmentId}")
    @RequiresPermissions("recruit_info:recruitmentinfor:info")
    public R info(@PathVariable("departmentId") Long departmentId){
        RecruitmentInforEntity recruitmentInfor = recruitmentInforService.getById(departmentId);

        return R.ok().put("recruitmentInfor", recruitmentInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("recruit_info:recruitmentinfor:save")
    public R save(@RequestBody RecruitmentInforEntity recruitmentInfor){
        recruitmentInforService.save(recruitmentInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("recruit_info:recruitmentinfor:update")
    public R update(@RequestBody RecruitmentInforEntity recruitmentInfor){
        ValidatorUtils.validateEntity(recruitmentInfor);
        recruitmentInforService.updateById(recruitmentInfor);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("recruit_info:recruitmentinfor:delete")
    public R delete(@RequestBody Long[] departmentIds){
        recruitmentInforService.removeByIds(Arrays.asList(departmentIds));

        return R.ok();
    }

}
